//引入依赖
var express = require('express');
//建立 express实例
var app = express();

app.get('/login', function(req, res){
	var result = {};
	//设置头部信息
	res.writeHead(200, {'Content-Type': 'application/json; charset=utf-8'});

	var admin = req.query.admin;
	var pwd = req.query.pwd;

	if (admin != null || pwd != null) {
		if (admin == 'rr' && pwd == '123') {
			result.code = 200;
			result.msg = '登录成功';
		} else {
			result.code = 200;
			result.msg = '账号或密码错误,登录失败';
		}
	} else {
		result.code = 200;
		result.msg = '账号或密码不能为空,登录失败';
	}

	res.write(JSON.stringify(result));
	res.end();
})

app.listen(3000);


